local nya__tianxiang = fk.CreateSkill {

  name = "nya__tianxiang",

  tags = {  },

}



nya__tianxiang:addEffect(fk.DamageInflicted, {
  name = "nya__tianxiang",
  anim_type = "offensive",
  events = {fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(nya__tianxiang.name) and not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    local to, card =  player.room:askForChooseCardAndPlayers(player, table.map(player.room:getOtherPlayers(player), function(p)
      return p.id end), 1, 1, ".|.|heart|hand", "#nya__tianxiang-choose", nya__tianxiang.name, true)
    if #to > 0 and card then
      event:setCostData(self, {to[1], card})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(event:getCostData(self)[1])
    room:obtainCard(to, event:getCostData(self)[2], true, fk.ReasonGive)
    local damage = table.simpleClone(data)
    damage.to = to
    room:damage(damage)
    if not to.dead then
      if to:hasSkill("nya__play", true) then
        room:damage{
          from = player,
          to = to,
          damage = 1,
          skillName = nya__tianxiang.name,
        }
      elseif not to:isNude() and not player.dead then
        local id = room:askForCardChosen(player, to, "he", nya__tianxiang.name)
        room:throwCard({id}, nya__tianxiang.name, to, player)
      end
    end
    return true
  end,
})

return nya__tianxiang